* Runs sector-level regressions and produces Table A.9 and list of events for footnote 4 of Appendix
 	
use "Empirics/AggregateData/Database/output/Database.dta", clear
cd "Empirics/AggregateData/Analysis"
set more off
graph drop _all

*. Run the following analys:
local sectoral           =1 // Table A.9

*. Where to store results
local outputfolder "../../../Output"

*. Set Window length
local windowstart=-4
local windowend=8

*. Minimum # years events need to be apart
local apart=4 // baseline

*. Create variables & Declare panel
qui do "Analysis_dofiles/CreateVars.do" `outputfolder'

*. Identify Large Devaluations
gen largeDevaluation = 1 if gER<=-0.20 & acceER<=-0.10 & gRER<=0

* Ensure events are X years apart, where X is given by `apart'
qui do "Analysis_dofiles/Apart.do" `apart' `outputfolder' `windowstart' `windowend' 

* Additional sample adjustments
qui do "Analysis_dofiles/Adjustments.do"

*. Extract list of events in the sample
qui do "Analysis_dofiles/ExtractList.do"

*. Generate Table 1:
qui do "Analysis_dofiles/Table1.do" `outputfolder'

sort id year

*. Create more variables:
qui do "Analysis_dofiles/CreateMoreVars.do"

if `sectoral'==1{
		qui do "Analysis_dofiles/Prep_for_Sectoral.do" `outputfolder'
		do "Analysis_dofiles/Regressions_Sectoral.do" `outputfolder'
}

cd ../../..
